<?php
try
{
   	error_reporting(E_ALL);
	ini_set('display_errors', '1');
    require_once ("Loader.php");
    $loader = new Loader();
    require_once (APP_PATH."/application/library/PHPExcel.php");
    require_once APP_PATH."/application/library/PhpWord/Autoloader.php";
    require_once (APP_PATH."/application/library/phpmailer.php");
    \PhpOffice\PhpWord\Autoloader::register();
    $configuration = new \library\configuration\Configuration(array("type"=>"ini"));
    \library\Registry::set("configuration",$configuration->initialize());
    $database  = new \model\database\Database();
    \library\Registry::set("database",$database->initialize());
    $cache = new library\cache\Cache();
    \library\Registry::set("cache",$cache->initialize());
    $session = new \library\Session\Session();
   \library\Registry::set("session",$session->initialize());
       
    $router = new library\Router\Router(
            array(
                "url" => (\library\RequestMethods::get("url")!=null ) ? \library\RequestMethods::get("url",null,false): "home/index",
                "extension" =>(\library\RequestMethods::get("url")!=null ) ? \library\RequestMethods::get("url",null,false): "html"
            ));
   \library\Registry::set("router",$router);
   $router->dispatch();
   if (\library\RequestMethods::get("url")!="home/indexNoJS" && \library\StringMethods::indexOf(\library\RequestMethods::get("url"),"ajax")==-1){
           ?>
           <noscript><meta http-equiv="refresh" content="0; url=/home/indexNoJS" /></noscript>
        <?php
       }
   unset($configuration);
   unset($session);
   unset($database);
   unset($cache);
   unset($router);
}
catch (library\exceptions\Exception401 $e){
    header("Location: /users/login");
}
catch (\library\exceptions\BaseException $e){
   // $_SESSION["error"]=  serialize($e);
   var_dump($e);
  // header("Location: /".$e->serverCode);
}
 catch (\Exception $e){
            var_dump($e);
 }
?>
